package ShuZu;

import java.util.Arrays;

/**数组冒泡排序*/
public class Array_GDBC_Demo03 {
    public static void main(String[] args) {
        int[] arr ={13,11,45,31,2};
//        method1(arr);
        method2(arr);
    }

    private static void method2(int[]arr) {
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
    }

    private static void method1(int[]arr) {
        for (int i = 1; i <arr.length ; i++) {
            for(int j = 0;j <arr.length-1;j++){
                if(arr[j]>arr[j+1]){
                    int t;
                    t = arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=t;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
